package com.cyf.plc.viewholder

import androidx.recyclerview.widget.RecyclerView
import com.cyf.plc.BR
import com.cyf.plc.adapter.AttributeAdapter
import com.cyf.plc.databinding.ItemAttributeBinding
import com.cyf.plc.model.PlcAttribute

class AttributeViewHolder(private val binding: ItemAttributeBinding) :
    RecyclerView.ViewHolder(binding.root) {

    fun bind(
        plcAttribute: PlcAttribute,
        onItemClickListener: AttributeAdapter.OnItemClickListener? = null
    ) {
        binding.setVariable(BR.plcAttribute, plcAttribute)

        onItemClickListener?.let { listener ->
            binding.root.setOnClickListener {
                listener.onItemClicked(plcAttribute, it)
            }
        }

    }
}